package com.library.power.util;

/**
 * 权限类别枚举类
 */
public enum PowerType {

	ENABLE_TO_MANAGE_ADMINS("管理管理员", PowerType.MANAGE_ADMINS_TYPE),
	ENABLE_TO_MANAGE_BOOKS("管理图书", PowerType.MANAGE_BOOKS),
	ENABLE_TO_MANAGE_STAFFS("管理员工", PowerType.MANAGE_STAFFS),
	ENABLE_TO_BORROW_BOOKS("图书借阅", PowerType.BORROW_BOOKS),
	ENABLE_TO_EVALUATE("图书评论", PowerType.EVALUATE),
	ENABLE_TO_BOOK_SEARCH("图书检索", PowerType.BOOK_SEARCH),
	ENABLE_TO_MANAGE_ROlES("管理角色", PowerType.MANAGE_ROLES),
	ENABLE_TO_MANAGE_BORROWS("管理借阅", PowerType.MANAGE_BORROWS);

	private final static int MANAGE_ADMINS_TYPE = 1;
	private final static int MANAGE_BOOKS= 2;
	private final static int MANAGE_STAFFS = 3;
	private final static int BOOK_SEARCH = 4;
	private final static int BORROW_BOOKS= 5;
	private final static int EVALUATE = 6;
	private final static int MANAGE_ROLES = 7;
	private final static int MANAGE_BORROWS = 8;

	private String name;
	private int type;

	PowerType(String name, int type) {
		this.name = name;
		this.type = type;
	}

	/**
	 * 获取权限类别名称
	 *
	 * @return
	 */
	public String getName() {
        return name;
    }

    /**
     * 获取权限类型
     *
     * @return
     */
    public int getType() {
        return type;
    }

	/**
	 * @return 是否有图书的管理权限
	 */
	public boolean hasBookManage() {
		return this.type == MANAGE_BOOKS;
	}


	/**
	 * @return 是否有员工的管理权限
	 */
	public boolean hasStaffManage() {
		return this.type == MANAGE_STAFFS;
	}

	/**
	 * @return 是否有管理员的管理权限
	 */
	public boolean hasAdminManage() {
		return this.type == MANAGE_ADMINS_TYPE;
	}

	/**
	 * @return 是否有借书权限
	 */
	public boolean hasBorrowBooks() {
		return this.type == BORROW_BOOKS;
	}

	/**
	 * @return 是否有评论权限
	 */
	public boolean hasEvaluate() {
		return this.type == EVALUATE;
	}

	/**
	 * @return 是否有图书检索权限
	 */
	public boolean hasSearchBooks() {
		return this.type == BOOK_SEARCH;
	}

	/**
	 * @return 是否有角色管理权限
	 */
	public boolean hasRoleManage() {
		return this.type == MANAGE_ROLES;
	}
}
